#include <chrono>
#include <future>
#include <iostream>
#include <thread>
void ptr(int a)
{
    std::cout << "PTR thread: " << a << std::endl;
}

void ptr1(int& a)
{
    std::cout << "before" << std::endl;
    std::cout << "PTR thread: " << a << std::endl;
    a = 2;
}

int ptr2(int a)
{
    std::cout << "PTR2 thread: " << a << std::endl;
    return a;
}

class X {
public:
    int get()
    {
	std::cout << "X" << std::endl;
	return 0;
    }
};

class Y {
public:
    int operator()()
    {
	std::cout << "Operator" << std::endl;
	return 1;
    }
};

int ptr3(int& a)
{
    return a;
}

int main(int argc, char* argv[])
{
    /*int para=1;
	std::thread a(ptr1,std::ref(para));
	a.join();
	std::cout<<"after: "<<para<<std::endl;*/

    /*指向类成员函数的指针
     	* X b;
    	std::thread a(&X::get, &b);

    	a.join();
	*/

    /*
	 * Y b;
	std::thread a(b);
	a.join();
	*/
    int a = 1;
    auto p = std::async(std::launch::async, ptr3, std::ref(a));
    std::cout << "Get future: " << p.get() << std::endl;
    return 0;
}
